@page "/setting"
@namespace SwashbucklerDiary.Rcl.Pages
@inherits ImportantComponentBase

<MyAppBar Title="@(I18n.T("Mine.Settings"))"
OnClick="NavigateToBack">
</MyAppBar>

<ScrollContainer>
    <div class="text-h6 setting-title">
        @(I18n.T("Setting.General.Name"))
    </div>

    <MCard Class="my-list-card"
    Elevation="0"
    Rounded="@("lg")">
        <MList>
            <MListItem OnClick="@(()=>To("permissionSetting"))">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-account-cog-outline
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.General.Permission.Name"))
                </MListItemContent>
                <MListItemAction>
                    <MIcon>mdi-chevron-right</MIcon>
                </MListItemAction>
            </MListItem>

            <MDivider Class="mx-5"></MDivider>

            <MListItem OnClick="@(()=>showClearCache=true)">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-trash-can-outline
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.General.Storage.Name"))
                </MListItemContent>
                <MListItemContent Class="setting-item-state">
                    <MListItemSubtitle>
                        @cacheSize
                    </MListItemSubtitle>
                </MListItemContent>
                <MListItemAction>
                    <MIcon>mdi-chevron-right</MIcon>
                </MListItemAction>
            </MListItem>
        </MList>
    </MCard>

    <div class="text-h6 setting-title">
        @(I18n.T("Setting.Display.Name"))
    </div>

    <MCard Class="my-list-card"
    Elevation="0"
    Rounded="@("lg")">
        <MList>
            <MListItem OnClick="@(()=>To("indexSetting"))">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-home-outline
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.Display.Index.Name"))
                </MListItemContent>
                <MListItemAction>
                    <MIcon>mdi-chevron-right</MIcon>
                </MListItemAction>
            </MListItem>
            <MDivider Class="mx-5"></MDivider>
            <MListItem OnClick="@(() => To("calendarSetting"))">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-calendar-month-outline
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.Display.Calendar.Name"))
                </MListItemContent>
                <MListItemAction>
                    <MIcon>mdi-chevron-right</MIcon>
                </MListItemAction>
            </MListItem>
            <MDivider Class="mx-5"></MDivider>
            <MListItem OnClick="@(()=>To("diarySetting"))">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-notebook-outline
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.Display.Diary.Name"))
                </MListItemContent>
                <MListItemAction>
                    <MIcon>mdi-chevron-right</MIcon>
                </MListItemAction>
            </MListItem>
            <MDivider Class="mx-5"></MDivider>
            <MListItem OnClick="@(()=>To("alertSetting"))">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-alert-box-outline
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.Display.Snackbars.Name"))
                </MListItemContent>
                <MListItemAction>
                    <MIcon>mdi-chevron-right</MIcon>
                </MListItemAction>
            </MListItem>
            <MDivider Class="mx-5"></MDivider>
            <MListItem OnClick="@(()=>To("diaryCardSetting"))">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-card-text-outline
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.Display.DiaryCard.Name"))
                </MListItemContent>
                <MListItemAction>
                    <MIcon>mdi-chevron-right</MIcon>
                </MListItemAction>
            </MListItem>
            <MDivider Class="mx-5 hidden-sm-and-down"></MDivider>
            <MListItem Class="hidden-sm-and-down">
                <MListItemIcon>
                    <MIcon Class="evident-icon">
                        mdi-chart-line
                    </MIcon>
                </MListItemIcon>
                <MListItemContent>
                    @(I18n.T("Setting.Display.StatisticsCard.Name"))
                </MListItemContent>
                <MListItemAction>
                    <SettingSwitch @bind-Value="showStatisticsCard"
                    SettingKey="@nameof(Setting.StatisticsCard)">
                    </SettingSwitch>
                </MListItemAction>
            </MListItem>
        </MList>
    </MCard>

    @if (PlatformIntegration.CurrentPlatform != AppDevicePlatform.Browser)
    {
        <div class="text-h6 setting-title">
            @(I18n.T("Setting.Other.Name"))
        </div>

        <MCard Class="my-list-card"
               Elevation="0"
               Rounded="@("lg")">
            <MList>
                <MListItem OnClick="@(()=>To("urlScheme"))">
                    <MListItemIcon>
                        <MIcon Class="evident-icon">
                            mdi-link-variant
                        </MIcon>
                    </MListItemIcon>
                    <MListItemContent>
                        Url Scheme
                    </MListItemContent>
                    <MListItemAction>
                        <MIcon>mdi-chevron-right</MIcon>
                    </MListItemAction>
                </MListItem>
            </MList>
        </MCard>
    }
    
</ScrollContainer>

<CustomMDialog @bind-MyValue="showClearCache"
                  ContentClass="rounded-lg"
                  MaxWidth="420">
    <MCard>
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Setting.General.Storage.Name"))
        </MCardTitle>
        <MCardText Class="pb-0">
            @(I18n.T("Storage.Content"))
        </MCardText>
        <MCardActions>
            <MSpacer></MSpacer>
            <MButton Text="true"
                     OnClick="()=>showClearCache=false">
                @(I18n.T("Share.Cancel"))
            </MButton>
            <MButton Text="true"
                     Color="red"
                     OnClick="ClearCache">
                @(I18n.T("Share.OK"))
            </MButton>
        </MCardActions>
    </MCard>
</CustomMDialog>
